<?php

namespace App\Repos;

use App\Models\Invite;
use App\Models\User;
use App\Models\Favorite;
use DB;

class FavoriteRepo 
{
    public static function getPages($where=[],$num=10)
    {
    	$list  = DB::table('favorites as i')
					->select(['u.nickname','u.face_score','u.sex','u.zhiye','u.avatar','i.created_at','i.favorite_user_id','u.avatar','u.wx_avatar',DB::raw('TIMESTAMPDIFF(YEAR, u.birthday, CURDATE()) AS age'),DB::raw('left(truename, 1) as firstname')])
					->leftJoin('users as u','u.id','=','i.favorite_user_id')
					->where($where)
					->paginate($num);
    	
    	return $list;
    }

    public static function save($data)
    {
        $rs['status'] = true;
      
       
        Favorite::create($data);
    	return $rs;
    }

    public static function find($where=[])
    {
        return Favorite::where($where)->first();
    }

    public static function delete($where)
    {
        return Favorite::where($where)->delete();
    }
}
